package mybatis;

import com.google.common.collect.ImmutableMap;
import org.apache.ibatis.ognl.OgnlException;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.vacoor.nothing.common.util.Resources;
import org.vacoor.nothing.web.dao.support.mbt.MyBatis;

import java.io.InputStream;

/**
 * @author vacoor
 */
public class Demo {

    public static void main(String[] args) throws OgnlException, ClassNotFoundException {
        MyBatis.bind("ext", ImmutableMap.<String, String>of("lang", "ss"));

        InputStream is = Resources.getResourceAsStream("mybatis-config.xml");
        SqlSessionFactory sf = new SqlSessionFactoryBuilder().build(is);
        SqlSession session = sf.openSession();

        TDao mapper = session.getMapper(TDao.class);
        String test = mapper.test();
        System.out.println(test);
    }
}
